package com.superm.service.impl;

import com.superm.entity.*;
import com.superm.mappers.WarehouseExitMapper;
import com.superm.service.WarehouseExitService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class WarehouseExitServiceImpl implements WarehouseExitService {


    @Autowired
    private WarehouseExitMapper warehouseExitMapper;
    /**
     * 实现模糊查询
     * @return
     */
    @Override
    public Map<String, Object> likeWarehouseExit(WarehouseExitPoJo warehouseExitPoJo,Integer pageNo,Integer pageSize) {
        //替换值
        WarehouseExit warehouseExit = new WarehouseExit();
        BeanUtils.copyProperties(warehouseExitPoJo,warehouseExit);
        //申请单
        warehouseExit.setPurchase(new Purchase(warehouseExitPoJo.getPurchase(),new RepostoryType(warehouseExitPoJo.getRepostoryId())));
        //经办人
        warehouseExit.setEmp(new Emp(warehouseExitPoJo.getEName()));
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("count",warehouseExitMapper.count(warehouseExit));
        map.put("data",warehouseExitMapper.likeMationInfo(warehouseExit,(pageNo-1)*pageSize,pageSize));
        return map;
    }
}
